package domain;

import java.util.Calendar;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.validator.constraints.NotEmpty;

/**
 *
 * @author yuyok
 */
@Entity(name = "Comment")
@NamedQueries({
    @NamedQuery(name = "getAllComments",
    query = "SELECT c FROM Comment c")
})
public class Comment extends DomainObject {

    private static final long serialVersionUID = 1L;
    @Lob //large object of type 'CHAR LARGE OBJECT'
    @NotEmpty(message="comment text can not be empty")
    private String text;
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar addedDate;
    @ManyToOne
    private User user;
    @ManyToOne
    private Video video;

    public Comment() {
    }

    public Comment(String text, Calendar addedDate, User user, Video video) {
        super();
        this.text = text;
        this.addedDate = addedDate;
        this.user = user;
        this.video = video;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public User getUser() {
        return this.user;
    }

    public void setVideo(Video video) {
        this.video = video;
    }

    public Video getVideo() {
        return this.video;
    }

    public void setAddedDate(Calendar addedDate) {
        this.addedDate = addedDate;
    }

    public Calendar getAddedDate() {
        return addedDate;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}
